﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TYBase;
using TYRTUBase;

namespace TYPLC.PLC {
    public abstract class CommPLCBase<T> : IPLCBase<T> {
        ITYClient connector;
        //这是一个串口,他需要串口参数
        public CommPLCBase(ITYClient rtu) {
            this.connector = rtu;
        }

        public override bool Connect() {
            if (connector.Connect() == false) {
                Log.I("连接失败...");
                return false;
            }
            //if (CheckAddress("D100") == false) {
            //    Log.I("检查地址失败");
            //    return false;
            //}
            return true;
        }


        public abstract override bool AddressAs(string address, out T data);

        public abstract override bool ReadPri(T address, out object value);

        public abstract override bool WritePri(T address, object value);
    }
}
